local sk__xingshuai = fk.CreateSkill {

  name = "sk__xingshuai",

  tags = {  },

}



sk__xingshuai:addEffect(fk.Damaged, {
  name = "sk__xingshuai",
  anim_type = "masochism",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(sk__xingshuai.name) and data.from and data.from ~= player and #player.room.alive_players > 1
  end,
  on_cost = function (self, event, target, player, data)
    local room = player.room
    local to = room:askForChoosePlayers(player, table.map(room:getOtherPlayers(player), Util.IdMapper), 1, 1,
      "#sk__xingshuai-choose", sk__xingshuai.name)
    if #to > 0 then
      event:setCostData(self, to[1])
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = room:getPlayerById(event:getCostData(self))
    local choice = room:askForChoice(to, {"sk__xingshuai_turnover", "sk__xingshuai_extraturn:"..player.id}, sk__xingshuai.name)
    if choice == "sk__xingshuai_turnover" then
      to:turnOver()
    else
      player:gainAnExtraTurn()
    end
  end,
})

return sk__xingshuai